export const downloadCvs2Img = (cvs,name) => {
	let $a = document.createElement('a');
	$a.download = name+'.jpg';
	$a.target = '_blank';
	const url = cvs.toDataURL("image/jpg");
	$a.href = url;
	if(typeof MouseEvent === 'function') {
		var evt = new MouseEvent('click', {
			view: window,
			bubbles: true,
			cancelable: false
		});
		$a.dispatchEvent(evt);
	} else {
		if(window.navigator.msSaveOrOpenBlob) {
			var bstr = atob(url.split(',')[1]);
			var n = bstr.length;
			var u8arr = new Uint8Array(n);
			while(n--) {
				u8arr[n] = bstr.charCodeAt(n);
			}
			var blob = new Blob([u8arr]);
			window.navigator.msSaveOrOpenBlob(blob, name+'.jpg');
		} else {
			var lang = model.get('lang');
			var html = '' +
				'<body style="margin:0;">' +
				'<img src="' + url + '" style="max-width:100%;" title="' + ((lang && lang[0]) || '') + '" />' +
				'</body>';
			var tab = window.open();
			tab.document.write(html);
		}
	}
}